From 13134a9fddb42a0d3e2836ea292f24ea8540a92b Mon Sep 17 00:00:00 2001 From: "kaf24@firebug.cl.cam.ac.uk" Date: Fri, 17 Mar 2006 11:44:55 +0100 Subject: [PATCH] Fix the gzip size extraction in xc_inflate_buffer(). Extract bytes as unsigned quantities. Signed-off-by: David Lively --- tools/libxc/xg_private.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tools/libxc/xg_private.c b/tools/libxc/xg_private.c index 65aae5de50..d86b9b10b7 100644 --- a/tools/libxc/xg_private.c +++ b/tools/libxc/xg_private.c @@ -77,10 +77,11 @@ char *xc_inflate_buffer(const char *in_buf, unsigned long in_size, return (char *)in_buf; } - out_len = in_buf[in_size-4] + - (256 * (in_buf[in_size-3] + - (256 * (in_buf[in_size-2] + - (256 * in_buf[in_size-1]))))); + out_len = (unsigned char)in_buf[in_size-4] + + (256 * ((unsigned char)in_buf[in_size-3] + + (256 * ((unsigned char)in_buf[in_size-2] + + (256 * (unsigned char)in_buf[in_size-1]))))); + bzero(&zStream, sizeof(zStream)); out_buf = malloc(out_len + 16); /* Leave a little extra space */ if ( out_buf == NULL ) -- 2.30.2